<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html lang="zh-CN">
  
  <head>
    
    <%@ include file="/WEB-INF/include/meta.jsp"%>
    <%@ include file="/WEB-INF/include/css.jsp"%>
    
  </head>
  <!-- end header -->
  <body>
    <div class="page-group">
      <div class="page page-current">
        
        <header class="bar bar-nav fs-header-small">
          <a href="${ctx.host}/profile/courses" class="icon icon-left pull-left"></a>
          <h1 class="title">我的课程</h1>
        </header>
        
        <div class="content">
        
          <div class="list-block media-list no-margin">
            <ul>
              <li class="course">
                <div class="item-content">
                  <div class="item-media"><img src="${cloud.prod}/${courseRound.course.cover}-avatar" style='width: 4rem;'></div>
                  <div class="item-inner">
                    <div class="item-title-row">
                      <div class="item-title">${courseRound.course.name}</div>
                    </div>
                    <div class="item-text">
                      <c:if test="${courseRound.code == null}">
                         您还未入团，请耐心等待~<br>
                      </c:if>
                      <c:if test="${courseRound.code != null}">
                        团课编号：${courseRound.groupAttr.description}，操房：${courseRound.groupAttr.gym}<br>
                      </c:if>
                      已上<span class="color-dark">&nbsp;${courseRound.finished}&nbsp;</span>节课，剩余&nbsp;<span class="color-dark">${courseRound.attrs['course_amount'].value == null ? (courseRound.course.hours - courseRound.finished) : (courseRound.attrs['course_amount'].value - courseRound.finished)}</span>&nbsp;节课。
                    </div>
                  </div>
                </div>
              </li>
            </ul>
          </div>
          
          <c:choose>
            <c:when test="${courseRound.courseStatus.prepare}">
              <div style="text-align: center; margin-top: 100px;">
                <img alt="" src="${ctx.resource}/image/hold.png" style="width: 100px;">
                <p class="color-gray no-margin" style="color: #A9B7B7;">分派团课中</p>
              </div>
            </c:when>
            
            <c:otherwise>
              
              <div class="schedule-warp" style="margin-top: 1rem;">
                <div class="content-padded no-margin">
                  <div class="row course-schedule">
                     <c:forEach var="courseSchedule" items="${courseRound.schedules}" varStatus="status">
                       <c:choose>
                         <c:when test="${courseSchedule.scheduleStatus.finish}">
                           <div class="col-33 finished">
                             <a href="${ctx.host}/profile/course-schedules/${courseSchedule.id}">
                               <fmt:formatDate value="${courseSchedule.occurDate}" pattern="MM月dd日"/><br>
                               ${courseSchedule.occurHour}<br>
                               <span style="color: #777; line-height: 1.2rem">查看寄语</span>
                             </a>
                             <span class="number">${status.index + 1}</span>
                           </div>
                         </c:when>
                         <c:when test="${courseSchedule.scheduleStatus.ready}">
                           <div class="col-33 waiting">
                             <a href="${ctx.host}/profile/course-schedules/${courseSchedule.id}">
                               <fmt:formatDate value="${courseSchedule.occurDate}" pattern="MM月dd日"/><br>
                               ${courseSchedule.occurHour}
                            </a>
                            <span class="number">${status.index + 1}</span>
                           </div>
                         </c:when>
                         <c:when test="${courseSchedule.scheduleStatus.expiry}">
                           <div class="col-33 expiry">
                             <a href="${ctx.host}/profile/course-schedules/${courseSchedule.id}">
                               <fmt:formatDate value="${courseSchedule.occurDate}" pattern="MM月dd日"/><br>
                               ${courseSchedule.occurHour}<br>
                               <span style="color: #777; line-height: 1.2rem">课程逾期</span>
                            </a>
                            <span class="number">${status.index + 1}</span>
                           </div>
                         </c:when>
                         <c:when test="${courseSchedule.scheduleStatus.schedule}">
                           <div class="col-33 undo">
                             <a href="javascript:void(0);">
                                <fmt:formatDate value="${courseSchedule.occurDate}" pattern="MM月dd日"/><br>
                                ${courseSchedule.occurHour}<br>
                                <span style="color: #777; line-height: 1.2rem">筹备中</span>
                             </a>
                             <span class="number">${status.index + 1}</span>
                           </div>
                         </c:when>
                         <c:otherwise>
                         </c:otherwise>
                       </c:choose>
                     </c:forEach>
                  </div>
                </div>
              </div>
            </c:otherwise>
           </c:choose>
           
        </div>
        <!-- End Content -->
        
      </div>
    </div>
    
    <%@ include file="/WEB-INF/include/script.jsp"%>
    <d:resource type="script" root="${ctx.resource}/build" src="js/page/course/course-detail.js" />
    <script type="text/javascript">
      require(['page/course/course-detail'], function(page) {
        page.init()
      })
    </script>
    
  </body>
</html>